import tkinter as tk
from tkinter import filedialog

# 移除逗号
def remove_commas(input_file, output_file):
    """
    读取输入文件，移除所有逗号后写入输出文件
    :param input_file: 输入文件路径
    :param output_file: 输出文件路径
    """
    with open(input_file, 'r', encoding='utf-8') as f_in, \
         open(output_file, 'w', encoding='utf-8') as f_out:
        for line in f_in:
            # 移除当前行的逗号并写入新文件
            f_out.write(line.replace(',', ''))

# 获取文件路径弹窗
# def get_file_paths():
#     # 创建主窗口
#     root = tk.Tk()
#     root.withdraw()  # 隐藏主窗口
#
#     # 弹出文件选择器获取 input_file
#     input_file = filedialog.askopenfilename(title="选择 input_file")
#
#     # 弹出文件选择器获取 output_file
#     output_file = filedialog.asksaveasfilename(title="选择 output_file")
#
#     # 返回输入的文件路径
#     return input_file, output_file



import tkinter as tk
from tkinter import simpledialog

import tkinter as tk
from tkinter import simpledialog


def get_file_paths():
    # 创建主窗口
    root = tk.Tk()
    root.withdraw()  # 隐藏主窗口

    # 弹出输入框获取 input_file 和 output_file
    input_output = simpledialog.askstring("输入", "请输入 input_file 路径: 和 output_file 路径:")

    # 将输入的字符串分割成两个路径
    input_file, output_file = input_output.split(" 和 ")

    # 返回输入的文件路径
    return input_file, output_file


# 调用函数获取路径
input_file, output_file = get_file_paths()
# 调用移除逗号函数
remove_commas(input_file, output_file)
print(f"input_file: {input_file}")
print(f"output_file: {output_file}")
